from TestCase import *

class GenTestCase(object):
	""" docs """
	def __init__(self,*args):
		""" docs """
		
		self.testcases = []
		self.photo = []
		
		return
	
	def AddTestCase(self, tcArg):
		""" Add a new testcase"""
		
		self.testcases.append(tcArg);
		
		return	
	
	def AddPhoto(self, listToAppend, value):
		""" Creates an image"""		

		photo = self.AppendToList(listToAppend, value)
		self.testcases.extend(photo);
		
		return

	def AppendToList(self, listToAppend, value):
		""" Append the input value to each element of testcases"""
		
		listRet = []
		for e in listToAppend :
			tmp = str(e) + " " + str(value)
			listRet.append(tmp)
			
		return listRet

	def Append(self, value):
		""" Append the input value to each element of testcases"""
		
		for i in range(len(self.testcases)) :
			self.testcases[i] += " " + str(value)
					
		return

	def Add(self, index, value):
		
		strCmdLine = ""
		for i in len(Attributes):
			attr = Attributes[i]
			
			strCmdLine += "-" + attr["name"]
			if( i != index):
				for d in attr.data:
					strCmdLine += str(d)
			else:
				strCmdLine += str(value)
		
		return
	
	def Print(self):
		
		#print self.testcases
		for tc in self.testcases :
			print tc
		
		return

	
	def Run(self):
		
		params = []
		hasParam = False
		strCmdLine = " "
		self.AddTestCase(strCmdLine)
		for attr in Attributes:
			strCmdLine = " -" + attr["name"]
			#self.Append(strCmdLine)
			if( attr["type"].startswith("tk_param") or attr["type"].startswith("tk_boolean")):
				hasParam = True
				self.Append(strCmdLine)
				# Every value of param adds a test case
				#Create Image of current state - MakeImage()
				photo = self.testcases
				self.testcases = [] # Empty TC and add photo appended with every param value
				for d in attr["data"]:
					self.AddPhoto(photo, " " + str(d))
					#self.Append(" " + str(d))
				#strCmdLine = ""
			else:
				for d in attr["data"]:
					strCmdLine += " " + str(d) 
				self.Append(strCmdLine)
				#self.AddTestCase(strCmdLine)
		
		# If param was present the Append last cmdlineArgs to EVERY element of testcases
##		if(hasParam == True ):
##			self.Append(strCmdLine)
##		else: # Here create the first test case
##			self.AddTestCase(strCmdLine)
				
		#for p in params:
		#	for d in p["data"]:
		#		self.Add(p, d)
		
		return	
	

if __name__ == '__main__':
	#print Attributes
	tc = GenTestCase()
	tc.Run()
	tc.Print()
